package com.example.streammessage;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.handler.annotation.SendTo;

/**
 * @author lee
 */
@EnableBinding({Sink.class})
@SpringBootApplication
public class StreamMessageApplication {


    public static void main(String[] args) {

        SpringApplication.run(StreamMessageApplication.class, args);
    }

    @StreamListener(Sink.INPUT)
    @SendTo(Processor.OUTPUT)
    public String handle(String person) {
        System.out.println("Received: " + person);
        return person.toUpperCase();
    }

    public static class Person {
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }
}
